<?php
/**
 *	CRUD Muitos para Um
 */
class PC4_Crud_ComCategorias extends PC4_Crud_Tabelas {
	
	public function __construct($config = null, $definition = null) {
    	if (is_string($config)) {
    		$config = array(
    			self::NAME => $config
    		);
    	}
    	$tabela = $config['name'];
    	$alias = $this->getAlias($tabela);
		$config = array_merge(array(
			'name' => $tabela,
			'tabelas' => array(
				$tabela . '_categorias cat' => array(
					'pk' => $alias . '.id_' . $tabela . '_categorias',
					'fk' => 'cat.id',
					'campos' => array('categoria' => 'nome')
				)
			)
		), (array)$config);
		parent::__construct($config, $definition);
	}
	
}